﻿using System;
namespace Doc.Xroad.Eu.Messages {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="GetDocumentRequest", Namespace="http://doc.x-road.eu/", Target=typeof(GetDocumentRequest))]
    public class GetDocumentRequestSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected GetDocumentRequest clazz;
        
        public GetDocumentRequestSerializer(GetDocumentRequest clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXmlAttributes(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXmlAttributes(Writer);
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("Id");
            if (clazz.Id!=null) {
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Id))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Id");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXmlAttributes(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXmlAttributes(Reader);
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="Id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>>GetDocument>Id");
                }
                clazz.Id = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Id")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>>>GetDocument>Id", Reader.LocalName);
            }
        }
    }
}
